namespace Warehouse

open System.Windows.Data
open Warehouse.Controls

open FSharp.Windows

module ProductSeach = 
    
    let createMvc model repository =
        let view = 
            {
                new StaticView<ProductSearchModel, ProductSearchWindow>() with 
                    member this.SetBindings model = 
                        Binding.FromExpression
                            <@ 
                                this.Control.OK.IsEnabled <- isNotNull model.SelectedProduct
                            @>
            }
        view.DefaultOKButton <- view.Control.OK

        Mvc(model, view, StaticViewController())
            .Compose(ProductSearchChildController(repository), ProductSearchPartialView(view.Control.ProductSearch))

